home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / SMAK124.ARJ / BBB.DOC next >
Text File  |  1992-04-13  |  13KB  |  309 lines

  1. Basic Building Blocks is a collection of QuickBasic subprograms and 
  2. assembler routines that I created and use for my own program development 
  3. as a self-employed programmer.  I try to make them as small, fast, and 
  4. efficient as is practical, and sometimes I even go way past being
  5. practical and stray into fanatical.
  6.  
  7. All routines come with fully documented source code.  I have made a 
  8. special effort to provide clean, clear, and complete documentation 
  9. within each source module itself.  I don't like having to reach for a 
  10. manual every time I need to check the syntax or function of a 
  11. routine, so I did away with the manual.  Everything you need to know 
  12. about a routine is in it.  I do like code that is educational and 
  13. teaches good programming techniques by example.  There is as much art 
  14. in creating a descriptive narrative as there is in creating efficient 
  15. computer code.  I try to do both.
  16.  
  17.  
  18. Basic Building Blocks current version:  1.00
  19.  
  20. Supports QuickBasic versions 3.0, 4.0, 4.5
  21.  
  22. Free updates are available for a one year period after the purchase date, 
  23. either by mail or modem.  By mail, send a blank, formatted diskette and a 
  24. self-addressed, stamped diskette mailer (or send $4 and I'll provide the 
  25. diskette, mailer, and stamps).  By modem, call (719) 382-8216 to reach 
  26. the BBS (2400 baud, N81).
  27.  
  28. If you think of a routine that would be a useful addition to this package,
  29. please tell me and I will consider creating it.  I have several planned 
  30. already, which is why I'm offering the free updates to initial purchasers.
  31.  
  32.  
  33. A simple example of the format used for all routines is shown below:
  34.  
  35.  
  36. ---------------------------- Begin CENTER.BAS ----------------------------
  37.  
  38. 'Purpose:  Centers text (or any other string) on screen.
  39. '
  40. ' Syntax:  call CenterText (text$, row)
  41. '
  42. '   Pass:  text$    String to center on screen.
  43. '          row      Row where string will display.
  44. '
  45. 'Returns:           nothing
  46. '
  47. '   Note:  Row should be 1 to 25.  String length should be <= 80.
  48. '          Screen width is assumed to be 80 characters.  Initial 
  49. '          cursor position is unchanged.  Color used for display
  50. '          is current color.
  51. '
  52.  
  53.  
  54. defint a-z
  55. sub CenterText (text$, row) static
  56.  
  57.   OldRow = csrlin : OldCol = pos(0)         'save current cursor position
  58.   locate row, 41 - (len(text$)+1) \ 2       'place cursor where printing begins
  59.   print text$;                              'display the text on-screen
  60.   locate OldRow, OldCol                     'restore initial cursor position
  61.  
  62. end sub
  63.  
  64. ----------------------------- End CENTER.BAS -----------------------------
  65.  
  66.  
  67.  
  68. List of current Basic Building Blocks routines (3/19/92):
  69.  
  70.  
  71. BAS file   Syntax and Use
  72. ---------  --------------
  73.  
  74. BITS       call ChkBit       (BitArray(), BitPos, BitOn)
  75.            call SetBit       (BitArray(), BitPos, BitValue)
  76.            call ToggleBits   (BitArray())
  77.            call CountSetBits (BitArray(), MaxBit, Count)
  78.            call FindNextBit  (BitArray(), BitPos, BitValue, Direction, Found)
  79.            
  80.            Collection of routines to manipulate individual bits in an integer
  81.            array.
  82.  
  83. BSEARCH    call SearchStrArray (SearchStr$, Array$(), Rank(), ElementNum)
  84.            Quickly searches any string array using pointers (binary search).
  85.  
  86. CENTERQ    call CenterText (Text$, row)
  87.            Centers a string on-screen at the desired row.
  88.            Uses PrintQ for fast screen writes.
  89.            
  90. CHECKKB    call CheckKB (WaitFlag, KeyPressed)
  91.            Reads chrs from keyboard, optionally waiting for a key press.
  92.            
  93. DATECNV    call ConvertDate (DateStr$, NumDays, WeekDay)
  94.            call RestoreDate (NumDays, DateStr$)
  95.            Facilitates date arithmetic.
  96.  
  97. DELAY      call Delay (DelayTime!)
  98.            Produces a timed delay, regardless of computer speed.
  99.            
  100. DOTPROF    call DotProfile (LowVal, HighVal, StepVal, StepLen, Score!, Graph$)
  101.            Draws a text-based, horizontal graph (like a thermometer graph).
  102.  
  103. DRAWBOXQ   call DrawBoxQ (ulr, ulc, lrr, lrc, BoxChar, BoxColor)
  104.            Draws a box frame on-screen.  Uses PrintQ for fast screen writes.
  105.  
  106. GETCOLOR   call GetColor (CurrentAttr)
  107.            Returns the current COLOR setting.
  108.             
  109. GETFIELD   call GetField (row, col, MaxLen, FillChr, Text$, CrsrPos, EditCode)
  110.            Replaces INPUT statement with full editing and re-entrancy.
  111.            Uses PrintQ for fast screen writes.
  112.  
  113. HEADER     '$include: 'header.bas'
  114.            Convenient first line for modules, sets constants.
  115.  
  116. INSSTR     call InsStr (MainStr$, FindStr$, ReplaceStr$, Found)
  117.            A find & replace utility for text strings.
  118.  
  119. MENUBOXQ   call MenuBoxQ (choice$(), prompt$(), BoxChr, Colors(), Flags, MenuChoice)
  120.            Displays a scrolling, bounce bar menu with item prompts.
  121.            Uses PrintQ for fast screen writes.
  122.  
  123. MSGBOXQ    call MsgBoxQ (message$(), TextColor, BoxChar, BoxColor, BoxWidth)
  124.            Display a window containing a message.  Uses PrintQ for fast 
  125.            screen writes.
  126.  
  127. PARSE      call Parse (Text$, Delimiter$, StartPos, SubStr$)
  128.            General purpose re-entrant parser.
  129.  
  130. SAVECRSR   call PushCrsr (CrsrStack())
  131.            call  PopCrsr (CrsrStack())
  132.            Used to save/restore cursor position & shape - may be nested 
  133.            10 deep.
  134.  
  135. STRIP      call Strip (Text$, chr)
  136.            Strips strings of unwanted leading and trailing chrs.
  137.  
  138. SORT       call SortStrArray (a$(), rank())
  139.            Sorts a string array using pointers.
  140.  
  141. SORT_STR   call SortFixedRecStr (RecStr$, RecLen, NumRec, rank())
  142.            Sorts fixed-length records in a record string using pointers.
  143.  
  144. YESORNO    call YesOrNo (KeyPressed)
  145.            Asks for a Yes or No response from operator.
  146.  
  147.  
  148.  
  149. ASM file   Syntax and Use
  150. ---------  --------------
  151.  
  152. CHNGCASE   call ChngCase (Action, Text$)
  153.            Converts a string to upper/lower case.
  154.  
  155. CHECKKB    call CheckKB (WaitFlag, KeyPressed)
  156.            Reads chrs from keyboard, optionally waiting for a key press.
  157.            Desqview, Windows, and OS/2 aware - releases time slice when
  158.            waiting for user input for optimal multitasking performance.
  159.  
  160. CRSRINFO   call CrsrInfo (Row, Col, Visible, StartLine, EndLine)
  161.            Returns info about the cursor position, shape, and on/off status.
  162.  
  163. CRYPT      call Crypt (Text$, Password$, Action)
  164.            Encrypts/decrypts any string.
  165.  
  166. DISKINFO   call DiskInfo (DriveLetter$, Bytes, Sectors, Clusters, ClustersFree)
  167.            Returns free space, used space, total space for desired drive.
  168.  
  169. EXIST      Exist (FileName$, Found)
  170.            Reports if a file currently exists.
  171.  
  172. FILEINFO   call FileInfo (FileSpec$, Found, Info$)
  173.            Checks if a file exists and returns its attributes, size, and 
  174.            date/time stamp in a string.  QB4+ only (uses long integers).
  175.  
  176. GETCPU     call GetCPU (ID)
  177.            Returns the current CPU type - 8088, 80286, 80386, or 80486.
  178.  
  179. GETFILES   GetFiles (FileSpec$, DirList$)
  180.            Read files names from a directory.
  181.            
  182. GETPATH    call GetPath (PathSpec$)
  183.            Returns the default drive and directory.
  184.            
  185. INTVAL     call IntVal (r$, Integer)
  186.            Fast replacement of VAL(r$) for integers only.
  187.  
  188. MIDCHAR    call MidChar (Text$, ChrPos, ChrCode)
  189.            Returns ASCII code of any character in a string.
  190.            Like QB's ChrCode = asc(mid$(Text$,ChrPos,1)), only faster!
  191.  
  192. PAINTBOX   call PaintBox (TRow, LCol, BRow, RCol, Attr)
  193.            Changes the color of a rectangular area on-screen without erasing
  194.            any text in the area.
  195.  
  196. PRINTQ     call PrintQ (Row, Col, Attr, Text$)
  197.            Displays strings on-screen QUICKLY using direct screen writes.
  198.            Desqview aware.
  199.  
  200. PRINTQA    call PrintQ (Row, Col, Attr, Text$)
  201.            Displays strings on-screen QUICKLY using direct screen writes.
  202.            Desqview aware.  Can change colors on a per character basis 
  203.            using embedded attribute codes in Text$
  204.            
  205. PUTCHAR    call PutChar (Text$, ChrPos, ChrCode)
  206.            Replaces any character in a string.
  207.            Like QB's mid$(Text$,ChrPos) = chr$(Chrcode), only faster!
  208.  
  209. PTRINIT    call PtrInit (NumElements, segment, offset)
  210.            Fast way to set the integer pointer array used by the sort routines.
  211.  
  212. REBOOT     call ReBoot (BootType)
  213.            Reboots the computer using either a warm or cold reboot.
  214.  
  215. SCANSTR    call ScanStr (StartPos, r$, ChrCode, Action, ChrPos)
  216.            Search a string forwards/backwards for the next character match/
  217.            nonmatch.
  218.  
  219. SCRLLBOX   call ScrollBox (ULRow, ULCol, LRRow, LRCol, Action, ColorCode)
  220.            Scroll or clear a rectangular area on-screen.
  221.  
  222. SCRNSR     call ScrnSave (ULrow, ULcol, LRrow, LRcol, Segment, Offset)
  223.            call ScrnRest (ULrow, ULcol, LRrow, LRcol, Segment, Offset)
  224.            Saves/restores a specified region of the display screen to an 
  225.            integer array in far memory.
  226.  
  227. SCRNCOPY   call ScrnCopy (Source, Destination)
  228.            Saves/restores entire screen displays using simplified 
  229.            parameters.
  230.  
  231. STRSAVE    call StrSave (r$, segment, offset)
  232.            call StrRest (r$, segment, offset)
  233.            Saves/Restores a string to far memory (an integer array).
  234.  
  235. TESTPRN    TestPrn (LPTPort, PrnOK)
  236.            Reports if printer is on-line and ready.
  237.  
  238.  
  239.  
  240. Utility programs  Use
  241. ----------------  ---
  242.  
  243. XQB4CAPS.BAS      Converts those $@#! upper case QB4 keywords in your source
  244.                   code file to easier-to-read lower case, without affecting 
  245.                   anything else.  Source code included.
  246.  
  247. XDOT.BAS          Converts old-style variable names containing periods in your
  248.                   source file to variable names without periods.
  249.                   
  250.                     Example:   old.style.name => OldStyleName
  251.                   
  252.                   Variable names using periods are so much easier to read, but
  253.                   Microsoft would like to see them used only for user-defined
  254.                   type fields.
  255.  
  256. READPRN.BAS       Reports the printer status for all three LPT ports.
  257.  
  258. DISKINFO.BAS      Reports hard drive partition sizes and percent free space.
  259.  
  260.  
  261.  
  262. Demo programs
  263. --------------
  264. Most routines are demonstrated with short, commented, example programs.
  265.  
  266. _BITS    BAS           _GETCOLR BAS           _PRINTQA BAS
  267. _CASE    BAS           _GETFILE BAS           _PUTCHAR BAS
  268. _CASEQB4 BAS           _GETPATH BAS           _READPRN BAS
  269. _CHKKB   BAS           _INSSTR  BAS           _ROUND   BAS
  270. _CNVDATE BAS           _MENUBOX BAS           _SAVCRSR BAS
  271. _CRSINFO BAS           _MIDCHAR BAS           _SCRLL   BAS
  272. _CRYPT   BAS           _MSGBOX  BAS           _SCRNCPY BAS
  273. _DRAWBOX BAS           _PARSE   BAS           _SORT    BAS
  274. _DSKINFO BAS           _PRINTA  BAS           _SORTSTR BAS
  275. _EXIST   BAS           _PRINTQ  BAS           _TESTPRN BAS
  276.  
  277.  
  278.  
  279.  
  280. About the author:
  281.  
  282. Ever wonder about the people who do this kind of stuff?  I do, so here's 
  283. a bit about me.
  284.  
  285. I earn my living as a self-employed computer programmer, consultant, and 
  286. systems integrator.  I'm have two kids (Miriam - Apr 87 and Eric - Jan 91), 
  287. who are driving my wife and me crazy with their boundless energy.  We are 
  288. energetic ourselves, preferring to ski, bicycle, play tennis, or hike, 
  289. but have been forced to put all that on low while we raise these little 
  290. rascals.  We all speak both French and English at home, though Miriam 
  291. has discovered that English is much more universal in our neighborhood 
  292. and is insisting on using it more and more, despite having learned French 
  293. first.  I'm a bit of a gourmet and like to grow my own vegetables because 
  294. they taste so much better.  I keep a trampoline in the back yard and use 
  295. it regularly and expertly.  Yes, like many computer people, I'm a little 
  296. bit strange.  My neighbors don't understand a grown man doing flips on a 
  297. trampoline.
  298.  
  299. I'm an independent soul, and I enjoy forming my own opinions.  When 
  300. something breaks, I prefer to fix it myself, regardless of the time it 
  301. takes, because I know I'll learn something, and probably do a better job 
  302. than most repairmen.  Learning, being independent, and doing the job 
  303. right are major motivators for me.  I am a critical observer, and pay 
  304. close attention to details, but also tend to think globally.  I'm betting 
  305. man will destroy his own environment, but I'm basically an optimist.
  306.  
  307. Gee, doctor, I feel a lot better now.  How much do I owe you?
  308.  
  309.